package com.eet.kafka.consumer;

import com.eet.kafka.constants.CommonConstants;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * Kafka消费者
 *
 * @author Administrator
 */
@Component
public class KafkaConsumer {

    /**
     * 监听队列
     *
     * @param record 消费记录实体
     */
    @KafkaListener(topics = {CommonConstants.TEST_TOPIC})
    public void subscribeMessage(ConsumerRecord<?, ?> record) {
        // 消费的哪个topic、partition的消息,打印出消息内容
        System.out.println("简单消费者: " + record.topic() + "-" + record.partition() + "-" + record.value());
    }
}
